using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.Serialization;
#if SILVERLIGHT
using System.Windows;
#endif

namespace WcfService1.DTO
{
    [DataContract]
    public class CashBankInDetailDTO : INotifyPropertyChanged
    {
        
        private Guid _CashBankInDetailId;
        private DepartemenDTO _Departemen;
        private Decimal _Kredit;
        private CoaDTO _FromAccount;
        private Decimal _Debit;
        private SalesInvoiceDTO _SalesInvoice;
        private int _No;
        private ObservableCollection<CoaDTO> _Coas;
        private ObservableCollection<SalesInvoiceDTO> _SalesInvoices;
        private ObservableCollection<DepartemenDTO> _Departemens;
        private CustomerDTO _Customer;
        private ObservableCollection<CustomerDTO> _Customers;
        private string _Description;

        #if SILVERLIGHT
        private Visibility _NonPaymentVisibility;
        private Visibility _PaymentVisibility;
#endif

        private bool _IsEnableDebit;
        private bool _IsEnableKredit;

        public CashBankInDetailDTO()
        {
            IsEnableDebit = true;
            IsEnableKredit = true;
        }

        [DataMember]
        public Guid CashBankInDetailId
        {
            get { return _CashBankInDetailId; }
            set
            {
                _CashBankInDetailId = value;
                RaisePropertyChanged("CashBankInDetailId");
            }
        }


        [DataMember]
        public SalesInvoiceDTO SalesInvoice
        {
            get { return _SalesInvoice; }
            set
            {
                if (ReferenceEquals(value, _SalesInvoice) || value == null) return;
                _SalesInvoice = value;
                RaisePropertyChanged("SalesInvoice");
            }
        }


        [DataMember]
        public CoaDTO FromAccount
        {
            get { return _FromAccount; }
            set
            {
                if (ReferenceEquals(value, _FromAccount) || value == null) return;
                _FromAccount = value;
                RaisePropertyChanged("FromAccount");
            }
        }


        [DataMember]
        public Decimal Debit
        {
            get { return _Debit; }
            set
            {
                _Debit = value;
                RaisePropertyChanged("Debit");
            }
        }


        [DataMember]
        public Decimal Kredit
        {
            get { return _Kredit; }
            set
            {
                _Kredit = value;
                RaisePropertyChanged("Kredit");
            }
        }


        [DataMember]
        public DepartemenDTO Departemen
        {
            get { return _Departemen; }
            set
            {
                if (ReferenceEquals(value, _Departemen) || value == null) return;
                _Departemen = value;
                RaisePropertyChanged("Departemen");
            }
        }


        [DataMember]
        public ObservableCollection<SalesInvoiceDTO> SalesInvoices
        {
            get { return _SalesInvoices; }
            set
            {
                if (ReferenceEquals(value,_SalesInvoices) || value == null)return;
                _SalesInvoices = value;
                RaisePropertyChanged("SalesInvoices");
            }
        }

        [DataMember]
        public ObservableCollection<CustomerDTO> Customers
        {
            get { return _Customers; }
            set
            {
                if (ReferenceEquals(value, _Customers) || value == null) return;
                _Customers = value;
                RaisePropertyChanged("Customers");
            }
        }

        [DataMember]
        public CustomerDTO Customer
        {
            get { return _Customer; }
            set
            {
                if (ReferenceEquals(value, _Customer) || value == null) return;
                _Customer = value;
                RaisePropertyChanged("Customer");
            }
        }

        [DataMember]
        public String Description
        {
            get { return _Description; }
            set
            {
                _Description = value;
                RaisePropertyChanged("Description");
            }
        }


        public int No
        {
            get { return _No; }
            set
            {
                _No = value;
                RaisePropertyChanged("No");
            }
        }

        public bool IsEnableDebit
        {
            get { return _IsEnableDebit; }
            set
            {
                _IsEnableDebit = value;
                RaisePropertyChanged("IsEnableDebit");
            }
        }

        public bool IsEnableKredit
        {
            get { return _IsEnableKredit; }
            set
            {
                _IsEnableKredit = value;
                RaisePropertyChanged("IsEnableKredit");
            }
        }


        public ObservableCollection<CoaDTO> Coas
        {
            get { return _Coas; }
            set
            {
                if (ReferenceEquals(value, _Coas) || value == null) return;
                _Coas = value;
                RaisePropertyChanged("Coas");
            }
        }

        public ObservableCollection<DepartemenDTO> Departemens
        {
            get { return _Departemens; }
            set
            {
                if (ReferenceEquals(value, Departemens) || value == null) return;
                _Departemens = value;
                RaisePropertyChanged("Departemens");
            }
        }

#if SILVERLIGHT
        public Visibility PaymentVisibility
        {
            get { return _PaymentVisibility; }
            set
            {
                //if (value == PaymentVisibility) return;
                _PaymentVisibility = value;
                RaisePropertyChanged("PaymentVisibility");
            }
        }

        public Visibility NonPaymentVisibility
        {
            get { return _NonPaymentVisibility; }
            set
            {
                //if (value == NonPaymentVisibility) return;
                _NonPaymentVisibility = value;
                RaisePropertyChanged("NonPaymentVisibility");
            }
        }
#endif

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion

        protected void RaisePropertyChanged(string propertyname)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
                handler(this, new PropertyChangedEventArgs(propertyname));
        }
    }
}